let common=require('../lib/common');
const route = require('../route');

module.exports = () => {
    return async (ctx, next) => {
        ctx.renderView =async function(views){
            common.loadStatic(ctx);
            let currentRoute=route.filter((item,index)=>{
                return item.match.includes(ctx.url);
            });
            let viewPath=currentRoute.length && currentRoute[0].controller.split(/\./)[0];
            await ctx.render(viewPath+'/'+views,ctx.state.scope);
        }
        await next();
    };
};